using System;
using System.Collections.Generic;
using BrainTechLLC;
using System.Collections;
using System.Text;

namespace Mud.EmlenMudMain
{
#if NO_SILVERLIGHT
    [Serializable]
#endif
    public class ShopData : IShopData
    {
        public Shop ToShop()
        {
            Shop result = new Shop()
            {
                Vnum = keeper
            };

            result.AddOrSetProperty("BuyType", this.buy_type);
            result.AddOrSetProperty("ProfitBuy", this.profit_buy);
            result.AddOrSetProperty("ProfitSell", this.profit_sell );
            result.AddOrSetProperty("OpenHour", this.open_hour );
            result.AddOrSetProperty("CloseHour", this.close_hour);
            result.AddOrSetProperty("CreatesHours", this.creates_hours );
            result.AddOrSetProperty("CreatesMessage", this.creates_message );
            result.AddOrSetProperty("CreatesVnum", this.creates_vnum);
            result.AddOrSetProperty("Decrease", this.decrease );
            result.AddOrSetProperty("ItemsUntilDecrease", this.items_until_decrease );
            
            result.Register();
            return result;
        }
        public ShopData() { }
        private int keeper;			/* VnumRoom of shopkeeper */

        public int Keeper
        {
            get { return keeper; }
            set { keeper = value; }
        }
        private List<int> buy_type = new List<int>(); 	/* What a shopkeeper will buy */

        public List<int> Buy_type
        {
            get { return buy_type; }
            set { buy_type = value; }
        }
        private int profit_buy;		/* Buying profit, in percent */

        public int Profit_buy
        {
            get { return profit_buy; }
            set { profit_buy = value; }
        }
        private int decrease;		/* Decrease percent for multiple items */

        public int Decrease
        {
            get { return decrease; }
            set { decrease = value; }
        }
        private int items_until_decrease;	/* Decrease percent after this many items */

        public int Items_until_decrease
        {
            get { return items_until_decrease; }
            set { items_until_decrease = value; }
        }
        private int profit_sell;		/* Selling profit, in percent */

        public int Profit_sell
        {
            get { return profit_sell; }
            set { profit_sell = value; }
        }
        private int open_hour;	/* Time the shop opens */

        public int Open_hour
        {
            get { return open_hour; }
            set { open_hour = value; }
        }
        private int close_hour;	/* Time the shop closes */

        public int Close_hour
        {
            get { return close_hour; }
            set { close_hour = value; }
        }
        private int creates_vnum;		/* Shopkeeper makes this object */

        public int Creates_vnum
        {
            get { return creates_vnum; }
            set { creates_vnum = value; }
        }
        private int creates_hours;	/* ever creates_hours hours. */

        public int Creates_hours
        {
            get { return creates_hours; }
            set { creates_hours = value; }
        }
        private string creates_message;	/* display this message when he/she creates */

        public string Creates_message
        {
            get { return creates_message; }
            set { creates_message = value; }
        }
    }

    // OLD CODE to PORT: Buying and Selling:

    //   CharacterData 
    //find_keeper (CharacterData  chr)
    //{
    //  CharacterData keeper;
    //  SHOP_DATA *pShop;
    //  pShop = NULL;
    //  check_room_more (chr->inRoom);
    //  for (keeper = chr->inRoom->MoreRoomInfo->people; keeper; keeper = keeper->next_in_room)
    //    {
    //      if (IS_MOB (keeper) && (pShop = keeper->pIndexData->pShop) != NULL)
    //   break;
    //    }
    //  if (pShop == NULL)
    //    {
    //      send_to_char ("You can't do that here.\n\r", chr);
    //      return NULL;
    //    }
    ///*
    //   * Shop hours.
    // */
    //  if (time_info.hour == 12)
    //    {
    //      do_say (keeper, "I'm on my lunch break, leave me be!");
    //      return NULL;
    //    }
    //  if (time_info.hour < pShop->open_hour)
    //    {
    //      do_say (keeper, "Sorry, try again later.");
    //      return NULL;
    //    }
    //  if (time_info.hour > pShop->close_hour)
    //    {
    //      do_say (keeper, "Sorry, we are closed.");
    //      return NULL;
    //    }
    ///*
    //   * Invisible or hidden people.
    // */
    //  if (!can_see (keeper, chr))
    //    {
    //      do_say (keeper, "What? Who said that?");
    //      return NULL;
    //    }
    //  return keeper;
    //}

    //CharacterData 
    //find_repair (CharacterData  chr, int rnum)
    //{
    //  CharacterData keeper;
    //  check_room_more (chr->inRoom);
    //  for (keeper = chr->inRoom->MoreRoomInfo->people; keeper; keeper = keeper->next_in_room)
    //    {
    //      if ((rnum == 1) && IS_MOB (keeper) && (IS_SET (keeper->currentActionsAndBehavior, REPAIRS_ONE)))
    //   break;
    //      if ((rnum == 2) && IS_MOB (keeper) && (IS_SET (keeper->currentActionsAndBehavior, REPAIRS_TWO)))
    //   break;
    //    }
    //  if (keeper == NULL)
    //    return NULL;
    //  if (!can_see (keeper, chr))
    //    {
    //      do_say (keeper, "What? Who said that?");
    //      return NULL;
    //    }
    //  return keeper;
    //}

    //int 
    //get_cost (CharacterData  keeper, SINGLE_OBJECT * obj, bool fBuy)
    //{
    //  SHOP_DATA *pShop;
    //  int cost;
    //  if (obj == NULL || (pShop = keeper->pIndexData->pShop) == NULL)
    //    return 0;
    //  if (fBuy)
    //    {
    //      cost = obj->cost * pShop->profit_buy / 96;
    //    }
    //  else
    //    {
    //      SINGLE_OBJECT *obj2;
    //      int itype;
    //      int tally;
    //      int origcost;
    //      cost = 0;
    //      tally = 0;
    //      for (itype = 0; itype < MAX_TRADE; itype++)
    //   {
    //     if (obj->pIndexData->item_type == pShop->buy_type[itype])
    //       {
    //         cost = obj->cost * pShop->profit_sell / 96;
    //         break;
    //       }
    //   }
    //      if (cost == 0)
    //   return 0;
    //      for (obj2 = keeper->carryingObjects; obj2; obj2 = obj2->next_content)
    //   {
    //     if (obj->pIndexData == obj2->pIndexData)
    //       tally++;
    //   }
    //      if (tally > keeper->pIndexData->pShop->items_until_decrease)
    //   {
    //     origcost = cost;
    //     cost -= ((tally - keeper->pIndexData->pShop->items_until_decrease) *
    //         (cost / (100 / keeper->pIndexData->pShop->decrease)));
    //     if (cost < 0)
    //       return 0;
    //   }
    //    }
    //  return cost;
    //}

    //void 
    //do_repair (CharacterData  chr, string szUserArguments)
    //{
    //  char buf[SML_LENGTH];
    //  char arg1[SML_LENGTH];
    //  char arg2[SML_LENGTH];
    //  CharacterData keeper;
    //  CharacterData keepert;
    //  SINGLE_OBJECT *obj;
    //  int repair_cost;
    //  bool warm;
    //  bool wrep;
    //  bool alll;
    //  DEFINE_COMMAND ("repair", do_repair, POSITION_STANDING, 0, NORMAL, "This command will repair a damaged weapon(s) or naturalArmor(s), depending on the shopkeeper present.")

    //    alll = FALSE;
    //  obj = NULL;
    //  repair_cost = 0;
    //  if (IS_MOB (chr))
    //    return;
    //  if (szUserArguments[0] == '\0')
    //    {
    //      send_to_char ("Syntax: Repair <item/all> to get the estimated cost.\n\r", chr);
    //      send_to_char (" Repair <item/all> YES to go ahead and repair the item.\n\r", chr);
    //      return;
    //    }
    //  szUserArguments = one_argy (szUserArguments, arg1);
    //  if (szUserArguments[0] != '\0')
    //    szUserArguments = one_argy (szUserArguments, arg2);
    //  else
    //    arg2[0] = '\0';
    //  if (!str_cmp (arg1, "all"))
    //    alll = TRUE;
    //  if (!alll && (obj = get_obj_inv (chr, arg1)) == NULL)
    //    {
    //      send_to_char ("You do not have that item.\n\r", chr);
    //      return;
    //    }
    //  if ((keeper = find_repair (chr, 1)) == NULL)
    //    wrep = FALSE;
    //  else
    //    wrep = TRUE;
    //  if ((keepert = find_repair (chr, 2)) == NULL)
    //    warm = FALSE;
    //  else
    //    warm = TRUE;
    //  if (keeper == NULL && keepert != NULL)
    //    keeper = keepert;
    //  if (!warm && !wrep)
    //    {
    //      send_to_char ("No-one here will repair any of your equipment.\n\r", chr);
    //      return;
    //    }
    //  if (alll)
    //    {
    //      /*REPAIR ALL */
    //      SINGLE_OBJECT *obj_nxt;
    //      int repair_cost_t;
    //      repair_cost_t = 0;
    //      for (obj = chr->carryingObjects; obj != NULL; obj = obj_nxt)
    //   {
    //     obj_nxt = obj->next_content;
    //     if (obj->next == NULL)
    //       obj_nxt = NULL;
    //     if (obj == NULL)
    //       {
    //         send_to_char ("Found nothing to repair.\n\r", chr);
    //         return;
    //       }
    //     if (obj->pIndexData->item_type != ITEM_WEAPON && obj->pIndexData->item_type != ITEM_ARMOR)
    //       continue;
    //     if (obj->pIndexData->item_type == ITEM_WEAPON && !wrep)
    //       continue;
    //     if (obj->pIndexData->item_type == ITEM_ARMOR && !warm)
    //       continue;
    //     if (obj->pIndexData->item_type == ITEM_WEAPON)
    //       {
    //         I_WEAPON *wp = (I_WEAPON *) obj->MoreRoomInfo;
    //         if (wp->firstdice * wp->seconddice < 17)
    //      repair_cost = (100 - wp->damage_p) * pow.repairWeapons[0];
    //         else if (wp->firstdice * wp->seconddice < 26)
    //      repair_cost = (100 - wp->damage_p) * pow.repairWeapons[1];
    //         else
    //      {
    //        if (LEVEL (keeper) > 75)
    //          repair_cost = (100 - wp->damage_p) * pow.repairWeapons[2];
    //        else
    //          {
    //            currentActionsAndBehavior ("$N's eyes widen when $S sees $p.\n\r$N refuses to touch such a powerful weapon.", chr, obj, keeper, TO_CHAR);
    //            continue;
    //          }
    //      }
    //         if (repair_cost < 1)
    //      continue;
    //       }
    //     if (obj->pIndexData->item_type == ITEM_ARMOR)
    //       {
    //         I_ARMOR *r = (I_ARMOR *) obj->MoreRoomInfo;
    //         repair_cost = (r->max_condition - r->condition_now) * pow.repairArmors;

    //         if (repair_cost < 1)
    //      continue;
    //       }
    //     sprintf (buf, "$N will repair $p for %d coins.", repair_cost);
    //     currentActionsAndBehavior (buf, chr, obj, keeper, TO_CHAR);
    //     if (is_member (chr, GUILD_TINKER))
    //       {
    //         currentActionsAndBehavior ("...but since you are a member of the Tinker's Guild...", chr, NULL, NULL, TO_CHAR);
    //         if (repair_cost > 6)
    //      {
    //        repair_cost = (repair_cost) -
    //          ((pow.tinkerDiscount * repair_cost) / 100);
    //      }
    //         sprintf (buf, "$N will repair $p for %d coins.", repair_cost);
    //         currentActionsAndBehavior (buf, chr, obj, keeper, TO_CHAR);
    //       }
    //     repair_cost_t += repair_cost;
    //     if (!(!str_cmp (arg2, "yes")))
    //       continue;
    //     if (tally_coins (chr) < repair_cost_t)
    //       {
    //         currentActionsAndBehavior ("You don't have enough money to repair everything!", chr, obj, NULL, TO_CHAR);
    //         return;
    //       }
    //   }
    //      /*END OBJ LIST */
    //      send_to_char ("------------------\n\r", chr);
    //      sprintf (buf, "Total: %d coins\n\r", repair_cost_t);
    //      send_to_char (buf, chr);
    //      if (!(!str_cmp (arg2, "yes")))
    //   return;
    //      send_to_char ("\n\r", chr);
    //      for (obj = chr->carryingObjects; obj != NULL; obj = obj_nxt)
    //   {
    //     obj_nxt = obj->next_content;
    //     if (obj->next == NULL)
    //       obj_nxt = NULL;
    //     if (obj->pIndexData->item_type != ITEM_WEAPON && obj->pIndexData->item_type != ITEM_ARMOR)
    //       continue;
    //     if (obj->pIndexData->item_type == ITEM_WEAPON && !wrep)
    //       continue;
    //     if (obj->pIndexData->item_type == ITEM_ARMOR && !warm)
    //       continue;

    //     if (obj->pIndexData->item_type == ITEM_WEAPON)
    //       {
    //         I_WEAPON *wp = (I_WEAPON *) obj->MoreRoomInfo;
    //         if (wp->damage_p > 99)
    //      continue;
    //       }

    //     if (obj->pIndexData->item_type == ITEM_ARMOR)
    //       {
    //         I_ARMOR *r = (I_ARMOR *) obj->MoreRoomInfo;
    //         if (r->max_condition == 0 || r->max_condition <= r->condition_now)
    //      continue;
    //       }

    //#ifdef NEW_WORLD
    //     if (obj->pIndexData->values_2[9] > 0 &&
    //         number_range (1, 1000) < obj->pIndexData->values_2[9])
    //       {
    //         currentActionsAndBehavior ("$B$7$N says, 'Woops... this is most unfortunate.'$R$7", chr, obj, keeper, TO_CHAR);
    //         currentActionsAndBehavior ("$B$7$N quickly sweeps up what remains of $p, now completely destroyed.$R$7", chr, obj, keeper, TO_CHAR);
    //         unequip_char (chr, obj);
    //         obj_from (obj);
    //         free_it (obj);
    //         continue;
    //       }
    //#endif
    //     currentActionsAndBehavior ("$N gives you back $p, brand new!", chr, obj, keeper, TO_CHAR);
    //     if (obj->pIndexData->item_type == ITEM_ARMOR)
    //       {
    //         I_ARMOR *r = (I_ARMOR *) obj->MoreRoomInfo;
    //         if (obj->wear_loc != WEAR_NONE)
    //      {
    //        int tempslot;
    //        tempslot = obj->wear_loc;
    //        unequip_char (chr, obj);
    //        r->condition_now = r->max_condition;
    //        equip_char (chr, obj, tempslot);
    //        continue;
    //      }
    //         else
    //      r->condition_now = r->max_condition;
    //         continue;
    //       }
    //     if (obj->pIndexData->item_type == ITEM_WEAPON)
    //       ((I_WEAPON *) obj->MoreRoomInfo)->damage_p = 100;
    //     continue;
    //   }
    //      if (repair_cost_t > 0)
    //   {
    //     sub_coins (repair_cost_t, chr);
    //     create_amount (repair_cost_t, keeper, NULL, NULL);
    //   }
    //      return;
    //    }
    ///*END REPAIR ALL */
    //  if (obj->pIndexData->item_type == ITEM_WEAPON && !wrep)
    //    {
    //      currentActionsAndBehavior ("$N can't repair weapons, only naturalArmor.", chr, NULL, keeper, TO_CHAR);
    //      return;
    //    }
    //  if (obj->pIndexData->item_type == ITEM_ARMOR && !warm)
    //    {
    //      currentActionsAndBehavior ("$N can't repair armors, only weapons.", chr, NULL, keeper, TO_CHAR);
    //      return;
    //    }
    //  if (obj->pIndexData->item_type != ITEM_WEAPON && obj->pIndexData->item_type != ITEM_ARMOR)
    //    return;
    //  if (obj->pIndexData->item_type == ITEM_WEAPON)
    //    {
    //      I_WEAPON *wp = (I_WEAPON *) obj->MoreRoomInfo;
    //      if (wp->firstdice * wp->seconddice < 17)
    //   repair_cost = (100 - wp->damage_p) * pow.repairWeapons[0];
    //      else if (wp->firstdice * wp->seconddice < 26)
    //   repair_cost = (100 - wp->damage_p) * pow.repairWeapons[1];
    //      else
    //   {
    //     if (LEVEL (keeper) > 75)
    //       repair_cost = (100 - wp->damage_p) * pow.repairWeapons[2];
    //     else
    //       {
    //         currentActionsAndBehavior ("$N's eyes widen when $S sees $p.\n\r$N refuses to touch such a powerful weapon.", chr, obj, keeper, TO_CHAR);
    //       }
    //   }
    //      if (repair_cost < 1)
    //   {
    //     send_to_char ("That object doesn't need any repair.\n\r", chr);
    //     return;
    //   }
    //    }
    //  else if (obj->pIndexData->item_type == ITEM_ARMOR)
    //    {
    //      I_ARMOR *r = (I_ARMOR *) obj->MoreRoomInfo;
    //      repair_cost = (r->max_condition - r->condition_now) * pow.repairArmors;


    //      if (repair_cost < 1)
    //   {
    //     send_to_char ("That object doesn't need any repair.\n\r", chr);
    //     return;
    //   }
    //    }
    //  else
    //    {
    //      send_to_char ("I can't repair that!\n\r", chr);
    //      return;
    //    }
    //  sprintf (buf, "$N will repair $p for %d coins.", repair_cost);
    //  currentActionsAndBehavior (buf, chr, obj, keeper, TO_CHAR);
    //  if (is_member (chr, GUILD_TINKER))
    //    {
    //      currentActionsAndBehavior ("...but since you are a member of the Tinker's Guild...", chr, NULL, NULL, TO_CHAR);
    //      if (repair_cost > 6)
    //   repair_cost = (repair_cost) -
    //     ((pow.tinkerDiscount * repair_cost) / 100);
    //      sprintf (buf, "$N will repair $p for %d coins.", repair_cost);
    //      currentActionsAndBehavior (buf, chr, obj, keeper, TO_CHAR);
    //    }
    //  if (!(!str_cmp (arg2, "yes")))
    //    return;
    //  if (tally_coins (chr) < repair_cost)
    //    {
    //      currentActionsAndBehavior ("You don't have enough money to repair $p!", chr, obj, NULL, TO_CHAR);
    //      return;
    //    }
    //  if (repair_cost > 0)
    //    {
    //      sub_coins (repair_cost, chr);
    //      create_amount (repair_cost, keeper, NULL, NULL);
    //    }
    //#ifdef NEW_WORLD
    //  if (obj->pIndexData->values_2[9] > 0 &&
    //      number_range (1, 1000) < obj->pIndexData->values_2[9])
    //    {
    //      currentActionsAndBehavior ("$B$7$N says, 'Woops... this is most unfortunate.'$R$7", chr, obj, keeper, TO_CHAR);
    //      currentActionsAndBehavior ("$B$7$N quickly sweeps up what remains of $p, now completely destroyed.$R$7", chr, obj, keeper, TO_CHAR);
    //      unequip_char (chr, obj);
    //      obj_from (obj);
    //      free_it (obj);
    //      return;
    //    }
    //#endif
    //  currentActionsAndBehavior ("That was sure fast! $N gives back $p, brand new!", chr, obj, keeper, TO_CHAR);
    //  if (obj->pIndexData->item_type == ITEM_ARMOR)
    //    {
    //      I_ARMOR *r = (I_ARMOR *) obj->MoreRoomInfo;
    //      if (obj->wear_loc != WEAR_NONE)
    //   {
    //     int tempslot;
    //     tempslot = obj->wear_loc;
    //     unequip_char (chr, obj);
    //     r->condition_now = r->max_condition;
    //     equip_char (chr, obj, tempslot);
    //     return;
    //   }
    //      else
    //   r->condition_now = r->max_condition;
    //      return;
    //    }
    //  if (obj->pIndexData->item_type == ITEM_WEAPON)
    //    ((I_WEAPON *) obj->MoreRoomInfo)->damage_p = 100;
    //  return;
    //}

    //void 
    //do_resize (CharacterData  chr, string szUserArguments)
    //{
    //  char buf[SML_LENGTH];
    //  char arg1[SML_LENGTH];
    //  char arg2[SML_LENGTH];
    //  CharacterData keeper;
    //  SINGLE_OBJECT *obj;
    //  I_ARMOR *r;
    //  int repair_cost;
    //  bool warm;
    //  bool alll;
    //  DEFINE_COMMAND ("resize", do_resize, POSITION_STANDING, 0, NORMAL, "This command allows you to resize an object (or objects) so that they fit you.  You must be at a shopkeeper.")
    //    alll = FALSE;
    //  obj = NULL;
    //  repair_cost = 0;

    //  if (IS_MOB (chr))
    //    return;
    //  if (szUserArguments[0] == '\0')
    //    {
    //      send_to_char ("Syntax: Resize <item/all> to get the estimated cost.\n\r", chr);
    //      send_to_char (" Resize <item/all> YES to go ahead and repair the item.\n\r", chr);
    //      return;
    //    }
    //  szUserArguments = one_argy (szUserArguments, arg1);
    //  if (szUserArguments[0] != '\0')
    //    szUserArguments = one_argy (szUserArguments, arg2);
    //  else
    //    arg2[0] = '\0';
    //  if (!str_cmp (arg1, "all"))
    //    alll = TRUE;
    //  if (!alll && (obj = get_obj_inv (chr, arg1)) == NULL)
    //    {
    //      send_to_char ("You do not have that item.\n\r", chr);
    //      return;
    //    }
    //  warm = TRUE;
    //  if ((keeper = find_repair (chr, 2)) == NULL)
    //    warm = FALSE;
    //  if (!warm)
    //    {
    //      send_to_char ("No-one here will resize any of your equipment.\n\r", chr);
    //      return;
    //    }
    //  if (alll)
    //    {
    //      /*REPAIR ALL */
    //      SINGLE_OBJECT *obj_nxt;
    //      int repair_cost_t;
    //      repair_cost_t = 0;
    //      for (obj = chr->carryingObjects; obj != NULL; obj = obj_nxt)
    //   {
    //     obj_nxt = obj->next_content;
    //     if (obj->next == NULL)
    //       obj_nxt = NULL;
    //     if (obj == NULL)
    //       {
    //         send_to_char ("Found nothing to resize.\n\r", chr);
    //         return;
    //       }
    //     if (obj->pIndexData->item_type != ITEM_ARMOR)
    //       continue;
    //     r = (I_ARMOR *) obj->MoreRoomInfo;
    //     if (obj->wear_loc != -1 || OBJ_FITS (obj, chr))
    //       continue;
    //     repair_cost = obj->cost / pow.resizeDivisor;
    //     if (repair_cost < 1)
    //       repair_cost = 1;
    //     sprintf (buf, "$N will resize $p for %d coins.", repair_cost);
    //     currentActionsAndBehavior (buf, chr, obj, keeper, TO_CHAR);
    //     repair_cost_t += repair_cost;
    //     if (!(!str_cmp (arg2, "yes")))
    //       continue;
    //     if (tally_coins (chr) < repair_cost_t)
    //       {
    //         currentActionsAndBehavior ("You don't have enough money to resize everything!", chr, obj, NULL, TO_CHAR);
    //         return;
    //       }
    //   }
    //      /*END OBJ LIST */
    //      send_to_char ("------------------\n\r", chr);
    //      sprintf (buf, "Total: %d coins\n\r", repair_cost_t);
    //      send_to_char (buf, chr);
    //      if (!(!str_cmp (arg2, "yes")))
    //   return;
    //      send_to_char ("\n\r", chr);
    //      for (obj = chr->carryingObjects; obj != NULL; obj = obj_nxt)
    //   {
    //     obj_nxt = obj->next_content;
    //     if (obj->next == NULL)
    //       obj_nxt = NULL;
    //     if (obj->pIndexData->item_type != ITEM_ARMOR || obj->wear_loc != -1 || OBJ_FITS (obj, chr))
    //       continue;
    //     currentActionsAndBehavior ("$N gives you back $p, fit to perfection!", chr, obj, keeper, TO_CHAR);
    //     SET_OBJ_SIZE (chr, obj);
    //     continue;
    //   }
    //      if (repair_cost_t > 0)
    //   {
    //     sub_coins (repair_cost_t, chr);
    //   }
    //      return;
    //    }
    //  if (obj->pIndexData->item_type != ITEM_ARMOR || obj->wear_loc != -1 || OBJ_FITS (obj, chr))
    //    {
    //      currentActionsAndBehavior ("Why would you want to resize that?", chr, NULL, keeper, TO_CHAR);
    //      return;
    //    }
    //  if (obj->pIndexData->item_type != ITEM_ARMOR)
    //    return;
    //  repair_cost = obj->cost / pow.resizeDivisor;
    //  if (repair_cost < 1)
    //    repair_cost = 1;
    //  sprintf (buf, "$N will resize $p for %d coins.", repair_cost);
    //  currentActionsAndBehavior (buf, chr, obj, keeper, TO_CHAR);
    //  if (!(!str_cmp (arg2, "yes")))
    //    return;
    //  if (tally_coins (chr) < repair_cost)
    //    {
    //      currentActionsAndBehavior ("You don't have enough money to resize $p!", chr, obj, NULL, TO_CHAR);
    //      return;
    //    }
    //  if (repair_cost > 0)
    //    {
    //      sub_coins (repair_cost, chr);
    //    }
    //  currentActionsAndBehavior ("$N gives back $p, fitted to perfection!", chr, obj, keeper, TO_CHAR);
    //  SET_OBJ_SIZE (chr, obj);
    //  return;
    //}

    //void 
    //do_buy (CharacterData  chr, string szUserArguments)
    //{
    //  char arg[SML_LENGTH];
    //  char tells[SML_LENGTH];
    //  DEFINE_COMMAND ("buy", do_buy, POSITION_STANDING, 0, NORMAL, "This command allows you to buy an item or pet from a shopkeeper in the currentRoom.")
    //    if (LEVEL (chr) > 100 && !IS_REAL_GOD (chr) && chr->inRoom->area->open == 1)
    //    {
    //      send_to_char ("Immorts can not buy or sell items in open areas.\n\r", chr);
    //      return;
    //    }
    //  szUserArguments = one_argy (szUserArguments, arg);
    //  if (arg[0] == '\0')
    //    {
    //      send_to_char ("Buy what?\n\r", chr);
    //      return;
    //    }
    //  if (IS_SET (chr->inRoom->rmflags, ROOM_PET_SHOP))
    //    {
    //      char buf[STD_LENGTH];
    //      CharacterData pet;
    //      ROOM_DATA *oneroomNext;
    //      ROOM_DATA *inRoom;
    //      if (IS_MOB (chr))
    //   return;
    //      oneroomNext = get_room_index (chr->inRoom->vnumClan + 1);
    //      if (oneroomNext == NULL)
    //   {
    //     bug ("Do_buy: bad pet shop at vnumClan %d.", chr->inRoom->vnumClan);
    //     send_to_char ("Sorry, you can't buy that here.\n\r", chr);
    //     return;
    //   }
    //      inRoom = chr->inRoom;
    //      chr->inRoom = oneroomNext;
    //      pet = get_char_room (chr, arg);
    //      chr->inRoom = inRoom;
    //      if (pet == NULL || !IS_SET (pet->currentActionsAndBehavior, ACT_PET))
    //   {
    //     send_to_char ("Sorry, you can't buy that here.\n\r", chr);
    //     return;
    //   }
    //      if (LEVEL (chr) < 17)
    //   if (chr->pcdata->number_pets > 1)
    //     {
    //       send_to_char ("You are unable to control that many pets at once!\n\r", chr);
    //       return;
    //     }
    //      if (LEVEL (chr) < 30)
    //   if (chr->pcdata->number_pets > 2)
    //     {
    //       send_to_char ("You are unable to control that many pets at once!\n\r", chr);
    //       return;
    //     }
    //      if (LEVEL (chr) < 50)
    //   if (chr->pcdata->number_pets > 3)
    //     {
    //       send_to_char ("You are unable to control that many pets at once!\n\r", chr);
    //       return;
    //     }
    //      if (chr->pcdata->number_pets > 4)
    //   {
    //     send_to_char ("You are unable to control that many pets at once!\n\r", chr);
    //     return;
    //   }
    //      if (tally_coins (chr) < 20 * LEVEL (pet) * LEVEL (pet))
    //   {
    //     send_to_char ("You can't afford it.\n\r", chr);
    //     return;
    //   }
    //      sprintf (buf, "You receive %s in change.\n\r",
    //          sub_coins (20 * LEVEL (pet) * LEVEL (pet), chr));
    //      send_to_char (buf, chr);
    //      chr->pcdata->number_pets++;
    //      pet = create_mobile (pet->pIndexData);
    //      SET_BIT (pet->currentActionsAndBehavior, ACT_PET);
    //      SET_BIT (pet->currentlyAffectedBy, AFF_CHARM);
    //      szUserArguments = one_argy (szUserArguments, arg);
    //      char_to_room (pet, chr->inRoom);
    //      add_follower (pet, chr);
    //      send_to_char ("Enjoy your pet.\n\r", chr);
    //      currentActionsAndBehavior ("$n bought $N as a pet.", chr, NULL, pet, TO_ROOM);
    //      return;
    //    }
    //  else
    //    {
    //      CharacterData keeper;
    //      SINGLE_OBJECT *obj;
    //      int cost;
    //      int looking;
    //      if ((keeper = find_keeper (chr)) == NULL)
    //   return;
    //      if (is_number (arg))
    //   {
    //     looking = atoi (arg);
    //     cost = 0;
    //     for (obj = keeper->carryingObjects; obj != NULL && cost < looking;
    //          obj = obj->next_content)
    //       {
    //         if (obj->wear_loc == WEAR_NONE
    //        || obj->wear_loc == WEAR_HOLD_1
    //        || obj->wear_loc == WEAR_HOLD_2)
    //      cost++;
    //       }
    //   }
    //      else
    //   obj = get_obj_inv (keeper, arg);
    //      if (obj)
    //   cost = get_cost (keeper, obj, TRUE);
    //      else
    //   cost = 0;
    //      if (!obj || cost <= 0 || !can_see_obj (chr, obj))
    //   {
    //     sprintf (tells, "%s I don't sell that.  Use the 'list' command to see what I sell.", NAME (chr));
    //     do_tell (keeper, tells);
    //     return;
    //   }
    //      if (!can_drop_obj (keeper, obj) && obj->pIndexData->item_type != ITEM_BOOK)
    //   {
    //     sprintf (tells, "%s I don't really want to sell it, sorry.", NAME (chr));
    //     do_tell (keeper, tells);
    //     return;
    //   }
    //      if (tally_coins (chr) < cost)
    //   {
    //     sprintf (tells, "%s You don't have enough money to buy %s.", NAME (chr),
    //         OOSTR (obj, short_descr));
    //     do_tell (keeper, tells);
    //     return;
    //   }

    //      currentActionsAndBehavior ("$n buys $p\x1B[0m from $N.", chr, obj, keeper, TO_ROOM);
    //      currentActionsAndBehavior ("You buy $p\x1B[0m from $N.", chr, obj, keeper, TO_CHAR);
    //      create_amount (cost, keeper, NULL, NULL);
    //      sub_coins (cost, chr);
    //      obj_from (obj);
    //      if (IS_SET (obj->extra_flags, ITEM_INVENTORY))
    //   obj->extra_flags ^= ITEM_INVENTORY;
    //      if (obj->pIndexData->item_type == ITEM_ARMOR)
    //   SET_OBJ_SIZE (chr, obj);
    //      obj_to_char (obj, chr);
    //      obj->wear_loc = -1;
    //      return;
    //    }
    //  return;
    //}

    //void 
    //do_list (CharacterData  chr, string szUserArguments)
    //{
    //  int listed_already[STD_LENGTH];
    //  int k;
    //  DEFINE_COMMAND ("list", do_list, POSITION_STANDING, 0, NORMAL, "This command allows you to list items or pets to buy if you are at a shop.")

    //    hugebuf_o[0] = '\0';
    //  if (IS_SET (chr->inRoom->rmflags, ROOM_PET_SHOP))
    //    {
    //      ROOM_DATA *oneroomNext;
    //      CharacterData pet;
    //      bool found;
    //      oneroomNext = get_room_index (chr->inRoom->vnumClan + 1);
    //      if (oneroomNext == NULL)
    //   {
    //     bug ("Do_list: bad pet shop at vnumClan %d.", chr->inRoom->vnumClan);
    //     send_to_char ("You can't do that here.\n\r", chr);
    //     return;
    //   }
    //      found = FALSE;
    //      check_room_more (oneroomNext);
    //      for (pet = oneroomNext->MoreRoomInfo->people; pet; pet = pet->next_in_room)
    //   {
    //     if (IS_SET (pet->currentActionsAndBehavior, ACT_PET))
    //       {
    //         if (!found)
    //      {
    //        found = TRUE;
    //        send_to_char ("Pets for sale:\n\r", chr);
    //      }
    //         sprintf (hugebuf_o, "%8d copper pieces - %s\n\r",
    //             20 * LEVEL (pet) * LEVEL (pet),
    //             SD (pet));
    //         send_to_char (hugebuf_o, chr);
    //       }
    //   }
    //      if (!found)
    //   send_to_char ("You notice a sign that reads:\n\rSorry, we're out of pets right now.\n\r", chr);
    //      return;
    //    }
    //  else
    //    {
    //      char arg[SML_LENGTH];
    //      CharacterData keeper;
    //      SINGLE_OBJECT *obj;
    //      bool flagx;
    //      int cost;
    //      int listcnt;
    //      int num;
    //      bool found;
    //      one_argy (szUserArguments, arg);
    //      if ((keeper = find_keeper (chr)) == NULL)
    //   return;
    //      listcnt = 0;
    //      found = FALSE;
    //      num = 0;
    //      for (k = 0; k < 1000; k++)
    //   {
    //     listed_already[k] = 0;
    //   }
    //      for (obj = keeper->carryingObjects; obj; obj = obj->next_content)
    //   {
    //     if ((obj->wear_loc == WEAR_NONE
    //          || obj->wear_loc == WEAR_HOLD_1
    //          || obj->wear_loc == WEAR_HOLD_2)
    //         && can_see_obj (chr, obj)
    //         && (cost = get_cost (keeper, obj, TRUE)) > 0
    //         && (arg[0] == '\0' || is_name (arg, obj->pIndexData->name)))
    //       {
    //         if (!found)
    //      {
    //        found = TRUE;
    //      }
    //         flagx = FALSE;
    //         for (k = 0; k < 1000; k++)
    //      {
    //        if (listed_already[k] == 0)
    //          break;
    //        if (listed_already[k] == obj->pIndexData->vnumClan)
    //          {
    //            flagx = TRUE;
    //            break;
    //          }
    //      }
    //         num++;
    //         if (flagx)
    //      continue;
    //         sprintf (hugebuf_o + strlen (hugebuf_o), "\x1B[0m[\x1B[1m%3d\x1B[0m] %s\x1B[0m for %s.\n\r", num - 1,
    //             ans_uppercase (OOSTR (obj, short_descr)),
    //             name_amount (cost));
    //         listed_already[listcnt] = obj->pIndexData->vnumClan;
    //         listcnt++;
    //         if (strlen (hugebuf_o) > 29500)
    //      {
    //        return;
    //      }
    //       }
    //   }
    //      if (found)
    //   {
    //     page_to_char (hugebuf_o, chr);
    //   }
    //      if (!found)
    //   {
    //     if (arg[0] == '\0')
    //       send_to_char ("There is nothing to buy.\n\r", chr);
    //     else
    //       send_to_char ("You can't buy that here.\n\r", chr);
    //   }
    //      return;
    //    }
    //  return;
    //}

    //void 
    //do_sell (CharacterData  chr, string szUserArguments)
    //{
    //  char buf[STD_LENGTH];
    //  char arg[SML_LENGTH];
    //  char tells[SML_LENGTH];
    //  CharacterData keeper;
    //  SINGLE_OBJECT *obj;
    //  int cost;
    //  DEFINE_COMMAND ("sell", do_sell, POSITION_STANDING, 0, NORMAL, "This command allows you to sell an item to a shopkeeper in the currentRoom.")

    //    one_argy (szUserArguments, arg);
    //  if (LEVEL (chr) > 100 && chr->inRoom->area->open == 1 && !IS_REAL_GOD (chr))
    //    {
    //      send_to_char ("Immorts can not buy or sell items in open areas.\n\r", chr);
    //      return;
    //    }
    //  if (arg[0] == '\0')
    //    {
    //      send_to_char ("Sell what?\n\r", chr);
    //      return;
    //    }
    //  if ((keeper = find_keeper (chr)) == NULL)
    //    return;
    //  if ((obj = get_obj_carry (chr, arg)) == NULL)
    //    {
    //      sprintf (tells, "%s You aren't holding that item!", NAME (chr));
    //      do_tell (keeper, tells);
    //      return;
    //    }
    //  if (!can_drop_obj (chr, obj) &&
    //      (obj->pIndexData->vnumClan != 6753)
    //    )
    //    {
    //      send_to_char ("You can't let go of it.\n\r", chr);
    //      return;
    //    }
    //  if ((cost = get_cost (keeper, obj, FALSE)) <= 0)
    //    {
    //      currentActionsAndBehavior ("$n looks at $p\x1B[0m and shakes $s head.", keeper, obj, chr, TO_VICT);
    //      return;
    //    }
    //  if (tally_coins (keeper) < cost)
    //    {
    //      currentActionsAndBehavior ("$n does not have enough money to buy $p\x1B[0m from you.", keeper,
    //      obj, chr, TO_VICT);
    //      return;
    //    }
    //  if ((IS_SET (obj->extra_flags, ITEM_NODROP) ||
    //       IS_SET (obj->extra_flags, ITEM_NOSAVE)) &&
    //      (obj->pIndexData->vnumClan != 6753)
    //    )
    //    {
    //      currentActionsAndBehavior ("$n does not want to buy that item from you!", keeper, obj, chr, TO_VICT);
    //      return;
    //    }
    //  currentActionsAndBehavior ("$n sells $p\x1B[0m to $N.", chr, obj, keeper, TO_ROOM);
    //  sprintf (buf, "You sell $p\x1B[0m for %s to $N.", name_amount (cost));
    //  currentActionsAndBehavior (buf, chr, obj, keeper, TO_CHAR);
    //  create_amount (cost, chr, NULL, NULL);
    //  sub_coins (cost, keeper);
    //  if (obj->pIndexData->item_type == ITEM_WEAPON)
    //    ((I_WEAPON *) obj->MoreRoomInfo)->damage_p = 100;
    //  if (obj->pIndexData->item_type == ITEM_ARMOR)
    //    ((I_ARMOR *) obj->MoreRoomInfo)->condition_now = ((I_ARMOR *) obj->MoreRoomInfo)->max_condition;
    //  if (obj->pIndexData->item_type == ITEM_TRASH)
    //    {
    //      currentActionsAndBehavior ("$n eats $p\x1B[0m, munching hungrily.", keeper, obj, NULL, TO_NOTVICT);
    //      free_it (obj);
    //    }
    //  else
    //    {
    //      if (!IS_SET (obj->extra_flags, ITEM_INVENTORY))
    //   obj->extra_flags ^= ITEM_INVENTORY;
    //      obj_from (obj);
    //      obj_to_char (obj, keeper);
    //    }
    //  return;
    //}

    //void 
    //do_value (CharacterData  chr, string szUserArguments)
    //{
    //  char arg[SML_LENGTH];
    //  char tells[SML_LENGTH];
    //  CharacterData keeper;
    //  SINGLE_OBJECT *obj;
    //  int cost;
    //  DEFINE_COMMAND ("value", do_value, POSITION_STANDING, 0, NORMAL, "This command shows you how much a shopkeeper will pay for a specific item.")

    //    one_argy (szUserArguments, arg);
    //  if (arg[0] == '\0')
    //    {
    //      send_to_char ("Value what?\n\r", chr);
    //      return;
    //    }
    //  if ((keeper = find_keeper (chr)) == NULL)
    //    return;
    //  if ((obj = get_obj_carry (chr, arg)) == NULL)
    //    {
    //      sprintf (tells, "%s You aren't holding that item!", NAME (chr));
    //      do_tell (keeper, tells);
    //      return;
    //    }
    //  if (!can_drop_obj (chr, obj) &&
    //      (obj->pIndexData->vnumClan != 6753))
    //    {
    //      send_to_char ("You can't let go of it.\n\r", chr);
    //      return;
    //    }
    //  if ((cost = get_cost (keeper, obj, FALSE)) <= 0)
    //    {
    //      currentActionsAndBehavior ("$n looks at $p\x1B[0m and shakes $s head.", keeper, obj, chr, TO_VICT);
    //      return;
    //    }
    //  sprintf (tells, "%s I guess I'd give you \x1B[0m%s for \x1B[0m%s.",
    //      NAME (chr),
    //      name_amount (cost),
    //      OOSTR (obj, short_descr));
    //  do_tell (keeper, tells);
    //  return;
    //}

}
